3.250 \(\int (a+b \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx\)

Optimal. Leaf size=140 \[ \frac{b \left (a^2 B+2 a A b-b^2 B\right ) \tan (c+d x)}{d}-\frac{\left (3 a^2 A b+a^3 B-3 a b^2 B-A b^3\right ) \log (\cos (c+d x))}{d}+x \left (a^3 A-3 a^2 b B-3 a A b^2+b^3 B\right )+\frac{(a B+A b) (a+b \tan (c+d x))^2}{2 d}+\frac{B (a+b \tan (c+d x))^3}{3 d} \]

[Out]

(a^3*A - 3*a*A*b^2 - 3*a^2*b*B + b^3*B)*x - ((3*a^2*A*b - A*b^3 + a^3*B - 3*a*b^2*B)*Log[Cos[c + d*x]])/d + (b
*(2*a*A*b + a^2*B - b^2*B)*Tan[c + d*x])/d + ((A*b + a*B)*(a + b*Tan[c + d*x])^2)/(2*d) + (B*(a + b*Tan[c + d*
x])^3)/(3*d)

________________________________________________________________________________________

Rubi [A]  time = 0.153958, antiderivative size = 140, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 3, integrand size = 23, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.13, Rules used = {3528, 3525, 3475} \[ \frac{b \left (a^2 B+2 a A b-b^2 B\right ) \tan (c+d x)}{d}-\frac{\left (3 a^2 A b+a^3 B-3 a b^2 B-A b^3\right ) \log (\cos (c+d x))}{d}+x \left (a^3 A-3 a^2 b B-3 a A b^2+b^3 B\right )+\frac{(a B+A b) (a+b \tan (c+d x))^2}{2 d}+\frac{B (a+b \tan (c+d x))^3}{3 d} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[c + d*x])^3*(A + B*Tan[c + d*x]),x]

[Out]

(a^3*A - 3*a*A*b^2 - 3*a^2*b*B + b^3*B)*x - ((3*a^2*A*b - A*b^3 + a^3*B - 3*a*b^2*B)*Log[Cos[c + d*x]])/d + (b
*(2*a*A*b + a^2*B - b^2*B)*Tan[c + d*x])/d + ((A*b + a*B)*(a + b*Tan[c + d*x])^2)/(2*d) + (B*(a + b*Tan[c + d*
x])^3)/(3*d)

Rule 3528

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(d
*(a + b*Tan[e + f*x])^m)/(f*m), x] + Int[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x
], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && GtQ[m, 0]

Rule 3525

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[(b*d*Tan[e + f*x])/f, x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int (a+b \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx &=\frac{B (a+b \tan (c+d x))^3}{3 d}+\int (a+b \tan (c+d x))^2 (a A-b B+(A b+a B) \tan (c+d x)) \, dx\\ &=\frac{(A b+a B) (a+b \tan (c+d x))^2}{2 d}+\frac{B (a+b \tan (c+d x))^3}{3 d}+\int (a+b \tan (c+d x)) \left (a^2 A-A b^2-2 a b B+\left (2 a A b+a^2 B-b^2 B\right ) \tan (c+d x)\right ) \, dx\\ &=\left (a^3 A-3 a A b^2-3 a^2 b B+b^3 B\right ) x+\frac{b \left (2 a A b+a^2 B-b^2 B\right ) \tan (c+d x)}{d}+\frac{(A b+a B) (a+b \tan (c+d x))^2}{2 d}+\frac{B (a+b \tan (c+d x))^3}{3 d}+\left (3 a^2 A b-A b^3+a^3 B-3 a b^2 B\right ) \int \tan (c+d x) \, dx\\ &=\left (a^3 A-3 a A b^2-3 a^2 b B+b^3 B\right ) x-\frac{\left (3 a^2 A b-A b^3+a^3 B-3 a b^2 B\right ) \log (\cos (c+d x))}{d}+\frac{b \left (2 a A b+a^2 B-b^2 B\right ) \tan (c+d x)}{d}+\frac{(A b+a B) (a+b \tan (c+d x))^2}{2 d}+\frac{B (a+b \tan (c+d x))^3}{3 d}\\ \end{align*}

Mathematica [C]  time = 0.966437, size = 130, normalized size = 0.93 \[ \frac{6 b \left (3 a^2 B+3 a A b-b^2 B\right ) \tan (c+d x)+3 b^2 (3 a B+A b) \tan ^2(c+d x)+3 (a-i b)^3 (B+i A) \log (\tan (c+d x)+i)+3 (a+i b)^3 (B-i A) \log (-\tan (c+d x)+i)+2 b^3 B \tan ^3(c+d x)}{6 d} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[c + d*x])^3*(A + B*Tan[c + d*x]),x]

[Out]

(3*(a + I*b)^3*((-I)*A + B)*Log[I - Tan[c + d*x]] + 3*(a - I*b)^3*(I*A + B)*Log[I + Tan[c + d*x]] + 6*b*(3*a*A
*b + 3*a^2*B - b^2*B)*Tan[c + d*x] + 3*b^2*(A*b + 3*a*B)*Tan[c + d*x]^2 + 2*b^3*B*Tan[c + d*x]^3)/(6*d)

________________________________________________________________________________________

Maple [A]  time = 0.013, size = 247, normalized size = 1.8 \begin{align*}{\frac{B \left ( \tan \left ( dx+c \right ) \right ) ^{3}{b}^{3}}{3\,d}}+{\frac{A \left ( \tan \left ( dx+c \right ) \right ) ^{2}{b}^{3}}{2\,d}}+{\frac{3\,B \left ( \tan \left ( dx+c \right ) \right ) ^{2}a{b}^{2}}{2\,d}}+3\,{\frac{Aa{b}^{2}\tan \left ( dx+c \right ) }{d}}+3\,{\frac{B{a}^{2}b\tan \left ( dx+c \right ) }{d}}-{\frac{B{b}^{3}\tan \left ( dx+c \right ) }{d}}+{\frac{3\,\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) A{a}^{2}b}{2\,d}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) A{b}^{3}}{2\,d}}+{\frac{B{a}^{3}\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) }{2\,d}}-{\frac{3\,\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) Ba{b}^{2}}{2\,d}}+{\frac{A{a}^{3}\arctan \left ( \tan \left ( dx+c \right ) \right ) }{d}}-3\,{\frac{A\arctan \left ( \tan \left ( dx+c \right ) \right ) a{b}^{2}}{d}}-3\,{\frac{B\arctan \left ( \tan \left ( dx+c \right ) \right ){a}^{2}b}{d}}+{\frac{B\arctan \left ( \tan \left ( dx+c \right ) \right ){b}^{3}}{d}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(d*x+c))^3*(A+B*tan(d*x+c)),x)

[Out]

1/3/d*B*tan(d*x+c)^3*b^3+1/2/d*A*tan(d*x+c)^2*b^3+3/2/d*B*tan(d*x+c)^2*a*b^2+3/d*A*a*b^2*tan(d*x+c)+3/d*B*a^2*
b*tan(d*x+c)-1/d*B*b^3*tan(d*x+c)+3/2/d*ln(1+tan(d*x+c)^2)*A*a^2*b-1/2/d*ln(1+tan(d*x+c)^2)*A*b^3+1/2/d*a^3*B*
ln(1+tan(d*x+c)^2)-3/2/d*ln(1+tan(d*x+c)^2)*B*a*b^2+1/d*a^3*A*arctan(tan(d*x+c))-3/d*A*arctan(tan(d*x+c))*a*b^
2-3/d*B*arctan(tan(d*x+c))*a^2*b+1/d*B*arctan(tan(d*x+c))*b^3

________________________________________________________________________________________

Maxima [A]  time = 1.48257, size = 193, normalized size = 1.38 \begin{align*} \frac{2 \, B b^{3} \tan \left (d x + c\right )^{3} + 3 \,{\left (3 \, B a b^{2} + A b^{3}\right )} \tan \left (d x + c\right )^{2} + 6 \,{\left (A a^{3} - 3 \, B a^{2} b - 3 \, A a b^{2} + B b^{3}\right )}{\left (d x + c\right )} + 3 \,{\left (B a^{3} + 3 \, A a^{2} b - 3 \, B a b^{2} - A b^{3}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 6 \,{\left (3 \, B a^{2} b + 3 \, A a b^{2} - B b^{3}\right )} \tan \left (d x + c\right )}{6 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^3*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

1/6*(2*B*b^3*tan(d*x + c)^3 + 3*(3*B*a*b^2 + A*b^3)*tan(d*x + c)^2 + 6*(A*a^3 - 3*B*a^2*b - 3*A*a*b^2 + B*b^3)
*(d*x + c) + 3*(B*a^3 + 3*A*a^2*b - 3*B*a*b^2 - A*b^3)*log(tan(d*x + c)^2 + 1) + 6*(3*B*a^2*b + 3*A*a*b^2 - B*
b^3)*tan(d*x + c))/d

________________________________________________________________________________________

Fricas [A]  time = 2.00174, size = 324, normalized size = 2.31 \begin{align*} \frac{2 \, B b^{3} \tan \left (d x + c\right )^{3} + 6 \,{\left (A a^{3} - 3 \, B a^{2} b - 3 \, A a b^{2} + B b^{3}\right )} d x + 3 \,{\left (3 \, B a b^{2} + A b^{3}\right )} \tan \left (d x + c\right )^{2} - 3 \,{\left (B a^{3} + 3 \, A a^{2} b - 3 \, B a b^{2} - A b^{3}\right )} \log \left (\frac{1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 6 \,{\left (3 \, B a^{2} b + 3 \, A a b^{2} - B b^{3}\right )} \tan \left (d x + c\right )}{6 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^3*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

1/6*(2*B*b^3*tan(d*x + c)^3 + 6*(A*a^3 - 3*B*a^2*b - 3*A*a*b^2 + B*b^3)*d*x + 3*(3*B*a*b^2 + A*b^3)*tan(d*x +
c)^2 - 3*(B*a^3 + 3*A*a^2*b - 3*B*a*b^2 - A*b^3)*log(1/(tan(d*x + c)^2 + 1)) + 6*(3*B*a^2*b + 3*A*a*b^2 - B*b^
3)*tan(d*x + c))/d

________________________________________________________________________________________

Sympy [A]  time = 0.571095, size = 240, normalized size = 1.71 \begin{align*} \begin{cases} A a^{3} x + \frac{3 A a^{2} b \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 3 A a b^{2} x + \frac{3 A a b^{2} \tan{\left (c + d x \right )}}{d} - \frac{A b^{3} \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac{A b^{3} \tan ^{2}{\left (c + d x \right )}}{2 d} + \frac{B a^{3} \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 3 B a^{2} b x + \frac{3 B a^{2} b \tan{\left (c + d x \right )}}{d} - \frac{3 B a b^{2} \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac{3 B a b^{2} \tan ^{2}{\left (c + d x \right )}}{2 d} + B b^{3} x + \frac{B b^{3} \tan ^{3}{\left (c + d x \right )}}{3 d} - \frac{B b^{3} \tan{\left (c + d x \right )}}{d} & \text{for}\: d \neq 0 \\x \left (A + B \tan{\left (c \right )}\right ) \left (a + b \tan{\left (c \right )}\right )^{3} & \text{otherwise} \end{cases} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))**3*(A+B*tan(d*x+c)),x)

[Out]

Piecewise((A*a**3*x + 3*A*a**2*b*log(tan(c + d*x)**2 + 1)/(2*d) - 3*A*a*b**2*x + 3*A*a*b**2*tan(c + d*x)/d - A
*b**3*log(tan(c + d*x)**2 + 1)/(2*d) + A*b**3*tan(c + d*x)**2/(2*d) + B*a**3*log(tan(c + d*x)**2 + 1)/(2*d) -
3*B*a**2*b*x + 3*B*a**2*b*tan(c + d*x)/d - 3*B*a*b**2*log(tan(c + d*x)**2 + 1)/(2*d) + 3*B*a*b**2*tan(c + d*x)
**2/(2*d) + B*b**3*x + B*b**3*tan(c + d*x)**3/(3*d) - B*b**3*tan(c + d*x)/d, Ne(d, 0)), (x*(A + B*tan(c))*(a +
 b*tan(c))**3, True))

________________________________________________________________________________________

Giac [B]  time = 3.8642, size = 2580, normalized size = 18.43 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^3*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

1/6*(6*A*a^3*d*x*tan(d*x)^3*tan(c)^3 - 18*B*a^2*b*d*x*tan(d*x)^3*tan(c)^3 - 18*A*a*b^2*d*x*tan(d*x)^3*tan(c)^3
 + 6*B*b^3*d*x*tan(d*x)^3*tan(c)^3 - 3*B*a^3*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) +
 tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^3*tan(c)^3 - 9*A*a^2*b*log(4*(tan(c)^2 +
1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan
(d*x)^3*tan(c)^3 + 9*B*a*b^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(
c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^3*tan(c)^3 + 3*A*b^3*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan
(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^3*tan(c)^3 -
 18*A*a^3*d*x*tan(d*x)^2*tan(c)^2 + 54*B*a^2*b*d*x*tan(d*x)^2*tan(c)^2 + 54*A*a*b^2*d*x*tan(d*x)^2*tan(c)^2 -
18*B*b^3*d*x*tan(d*x)^2*tan(c)^2 + 9*B*a*b^2*tan(d*x)^3*tan(c)^3 + 3*A*b^3*tan(d*x)^3*tan(c)^3 + 9*B*a^3*log(4
*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan
(c) + 1))*tan(d*x)^2*tan(c)^2 + 27*A*a^2*b*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + t
an(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^2*tan(c)^2 - 27*B*a*b^2*log(4*(tan(c)^2 + 1
)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(
d*x)^2*tan(c)^2 - 9*A*b^3*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^
2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^2*tan(c)^2 - 18*B*a^2*b*tan(d*x)^3*tan(c)^2 - 18*A*a*b^2*tan
(d*x)^3*tan(c)^2 + 6*B*b^3*tan(d*x)^3*tan(c)^2 - 18*B*a^2*b*tan(d*x)^2*tan(c)^3 - 18*A*a*b^2*tan(d*x)^2*tan(c)
^3 + 6*B*b^3*tan(d*x)^2*tan(c)^3 + 18*A*a^3*d*x*tan(d*x)*tan(c) - 54*B*a^2*b*d*x*tan(d*x)*tan(c) - 54*A*a*b^2*
d*x*tan(d*x)*tan(c) + 18*B*b^3*d*x*tan(d*x)*tan(c) + 9*B*a*b^2*tan(d*x)^3*tan(c) + 3*A*b^3*tan(d*x)^3*tan(c) -
 9*B*a*b^2*tan(d*x)^2*tan(c)^2 - 3*A*b^3*tan(d*x)^2*tan(c)^2 + 9*B*a*b^2*tan(d*x)*tan(c)^3 + 3*A*b^3*tan(d*x)*
tan(c)^3 - 2*B*b^3*tan(d*x)^3 - 9*B*a^3*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(
d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)*tan(c) - 27*A*a^2*b*log(4*(tan(c)^2 + 1)/(tan(
d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)*ta
n(c) + 27*B*a*b^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(
d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)*tan(c) + 9*A*b^3*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d
*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)*tan(c) + 36*B*a^2*b*tan(d*x
)^2*tan(c) + 36*A*a*b^2*tan(d*x)^2*tan(c) - 18*B*b^3*tan(d*x)^2*tan(c) + 36*B*a^2*b*tan(d*x)*tan(c)^2 + 36*A*a
*b^2*tan(d*x)*tan(c)^2 - 18*B*b^3*tan(d*x)*tan(c)^2 - 2*B*b^3*tan(c)^3 - 6*A*a^3*d*x + 18*B*a^2*b*d*x + 18*A*a
*b^2*d*x - 6*B*b^3*d*x - 9*B*a*b^2*tan(d*x)^2 - 3*A*b^3*tan(d*x)^2 + 9*B*a*b^2*tan(d*x)*tan(c) + 3*A*b^3*tan(d
*x)*tan(c) - 9*B*a*b^2*tan(c)^2 - 3*A*b^3*tan(c)^2 + 3*B*a^3*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan
(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)) + 9*A*a^2*b*log(4*(tan(c)^2 + 1)/(
tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)) - 9*B*a
*b^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*ta
n(d*x)*tan(c) + 1)) - 3*A*b^3*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan
(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)) - 18*B*a^2*b*tan(d*x) - 18*A*a*b^2*tan(d*x) + 6*B*b^3*tan(d*x) -
18*B*a^2*b*tan(c) - 18*A*a*b^2*tan(c) + 6*B*b^3*tan(c) - 9*B*a*b^2 - 3*A*b^3)/(d*tan(d*x)^3*tan(c)^3 - 3*d*tan
(d*x)^2*tan(c)^2 + 3*d*tan(d*x)*tan(c) - d)